package chances.epg.ui.widget.taglib;

import java.util.List;

import chances.epg.data.PageBean;
import chances.epg.data.taglib.page.PageInfo;
import chances.epg.ui.widget.model.DataModel;
import chances.epg.ui.widget.model.GridWidgetModel;
import chances.epg.ui.widget.model.WidgetModel;

@SuppressWarnings("serial")
public class GridWidgetTag extends WidgetTag {

	private GridWidgetModel gridWidgetModel = new GridWidgetModel();

	public void setAxis(String axis) {
		gridWidgetModel.setAxis(axis);
	}

	@Override
	public void reset() {
		super.reset();
		this.gridWidgetModel = new GridWidgetModel();
	}

	public void setId(String id) {
		gridWidgetModel.setId(id);
	}

	public void setRow(int row) {
		gridWidgetModel.setRow(row);
	}

	public void setCol(int col) {
		gridWidgetModel.setCol(col);
	}

	public void setDatas(List<DataModel> datas) {
		gridWidgetModel.setDatas(datas);
	}

	

	public void setNextUrl(String nextUrl) {
		gridWidgetModel.setNextUrl(nextUrl);
	}

	public void setPrevUrl(String prevUrl) {
		gridWidgetModel.setPrevUrl(prevUrl);
	}

	public void setRecordCount(int recordCount) {
		gridWidgetModel.setRecordCount(recordCount);
	}

	public void setRowspace(int rowspace) {
		gridWidgetModel.setRowspace(rowspace);
	}

	public void setColspace(int colspace) {
		gridWidgetModel.setColspace(colspace);
	}

	public void setPageInfo(Object a) {
		if (PageInfo.class.isInstance(a)) {
			PageInfo aPageInfo = (PageInfo) a;
			this.gridWidgetModel.setNextUrl(aPageInfo.getNextUri());
			this.gridWidgetModel.setPrevUrl(aPageInfo.getPrevUri());
			this.gridWidgetModel.setRecordCount(aPageInfo.getRecordCount());
			this.gridWidgetModel.setPageNo(aPageInfo.getPageIndex());

		}
	}

	public void setPageBean(Object pageBean) {
		if (PageBean.class.isInstance(pageBean)) {
			PageBean aPageBean = (PageBean) pageBean;
			this.gridWidgetModel.setRecordCount(aPageBean.getRecordCount());
			this.gridWidgetModel.setPageNo(aPageBean.getCurrentPage());
		}
	}

	@Override
	public WidgetModel getModel() {
		return this.gridWidgetModel;
	}

}
